package com.hmall.item.Interceptor;

import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

@Slf4j
@Component
public class RequestInterceptor implements feign.RequestInterceptor {
//feign拦截器 添加请求头
    @Override
    public void apply(RequestTemplate requestTemplate) {
        /*ServletRequestAttributes servletRequestAttributes =
                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();*/

        log.info("===request: {}", requestTemplate.url());
        requestTemplate.header("authorization", "2");
    }
}
